package com.open.capacity.user.service.impl;

import com.github.pagehelper.PageInfo;
import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.common.model.SysResume;
import com.open.capacity.common.model.SysRole;
import com.open.capacity.common.model.SysUser;
import com.open.capacity.common.util.PageUtil;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.user.dao.SysResumeDao;
import com.open.capacity.user.service.SysResumeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@Service
public class SysResumeServiceIpml implements SysResumeService {

    @Autowired
    private SysResumeDao sysResumeDao;

    @Override
    public int save(SysResume sysResume) {
        return sysResumeDao.save(sysResume);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return sysResumeDao.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(SysResume sysResume) {
        return sysResumeDao.updateByPrimaryKey(sysResume);
    }


    @Override
    public int count(Map<String, Object> params) {
        return sysResumeDao.count(params);
    }

    @Override
    public PageResult<SysResume> findList(Map<String, Object> params) {
        try {
            int total = sysResumeDao.count(params);
            List<SysResume> list = Collections.emptyList();
            if (total > 0) {
                PageUtil.pageParamConver(params, true);
                list = sysResumeDao.findList(params);
            }
            return PageResult.<SysResume>builder().data(list).code(200).count((long) total).build();
        } catch (Exception e) {
            throw new ServiceException(e);
        }

    }
    @Override
    public SysResume findById(String id){
        return sysResumeDao.findById(id);
    }
}
